package cn.fl.project.service;

import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.fl.audit.vo.AudCreditInfoVO;
import cn.fl.audit.vo.AudReturnVisitVO;
import cn.fl.customer.vo.CstBscInfoVO;
import cn.fl.product.vo.PrdBscInfoVO;
import cn.fl.project.condition.PrjBscInfoQueryCondition;
import cn.fl.project.dto.PrjBscInfoDTO;
import cn.fl.project.dto.PrjCheckResultDTO;
import cn.fl.project.dto.PrjPopuInfoDTO;
import cn.fl.project.vo.*;
import cn.fl.system.vo.SysUlFilesRecVO;
import cn.fl.system.vo.SysUsrVO;
import com.itextpdf.text.Document;
import com.lionbridge.activiti.dto.MessageDTO;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import net.sf.json.JSONArray;

import java.io.OutputStream;
import java.util.List;
import java.util.Map;

/**
 * @Description: 项目基础信息表 客户端服务层接口
 * 业务层方法名称前缀：
 * 新增：add*
 * 删除：remove*
 * 修改：modify*
 * 批量：batch*
 * 查询对象：select* get*
 * 查询集合：search*
 */
public interface IPrjBscInfoService {
	
	/**
	 * 获取唯一对象
	 * @param id 主键
	 * @return 对象DTO
	 */
	public PrjBscInfoVO selectById(Long id)throws BaseException;

	/**
	 * 根据组织架构获取阈值
	 * @param 
	 * @return String
	 */
	public String searchSysCtrlCfgByCtrlCode()throws BaseException;
	
	/**
	 * 新增
	 * @param entity
	 * @return
	 */
    public Long add(PrjBscInfoVO entity) throws BaseException;

    /**
     * 删除
     * @param id
     * @return
     */
    public boolean removeById(Long id)throws BaseException;

    /**
     * 修改
     * @param entity
     * @return
     */
    public boolean modify(PrjBscInfoVO entity)throws BaseException;
    
    public boolean modifyPrjBscInfo(PrjBscInfoVO entity) throws BaseException;

    /**
     * 分页查询所有
     * @param page
     * @return
     */
    public Pager searchListPage(Pager page)throws BaseException;
    
    /**
     * 分页查询所有(查重)
     * @param page
     * @return
     */
    public Pager searchReListPage(Pager page)throws BaseException;
    
    /**
     * 分页查询指定项目
     * @param page
     * @return
     */
    public Pager searchOldListPage(Pager page)throws BaseException;
    
	/**
	 * 根据用户ID和业务主键等参数启动流程
	 * @param flowStartParamsDTO 启动参数
	 */
	public DataResultDTO addFlowStart(FlowStartParamsDTO flowStartParamsDTO)throws BaseException;
	/**
	 * 项目类型
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getProjectTypeList() throws BaseException;

    /**
     * 项目类型 包含删除和无效数据
     * @return
     * @throws BaseException
     */
    public List<KeyValueVO> getPrjTypCdALLKV() throws BaseException;

	/**
	 * 业务来源
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getBizResTypeList() throws BaseException;
	/**
	 *数据来源
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getDsList() throws BaseException;
	/**
	 * 项目状态
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getPrjStsList() throws BaseException;
	/**
	 * 业务类型
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getBizTypeList() throws BaseException;

	/**
	 * GPS审核状态
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getGPSAudStsList() throws BaseException;

    /**
     * 合格证审核状态
     * @return
     * @throws BaseException
     */
    List<KeyValueVO> getAudStsList() throws BaseException;
	/**
	 * gps厂家
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getGpsNmList() throws BaseException;
	/**
	 * gps类型
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getGpsTypList() throws BaseException;
	/**
	 * 获取产品类型值
	 * @return
	 * @throws BaseException
	 */
	public String getPrdTypVal(String prdTypCd) throws BaseException;
	/**
	 * 根据组织机构获取客户列表 
	 * @param orgCd
	 * @return
	 */
	public List<SysUsrVO> getCstMgrListByOrgId(String orgCd) throws BaseException;
	
	/**
	 * 根据组织机构获取客户列表 
	 * @param page
	 * @return
	 */
	public Pager getCstMgrListByOrgIdPage(Pager page) throws BaseException;
	/**
	 * 获取厂商列表
	 * @return
	 */
	public JSONArray getMfrKvlist(String name) throws BaseException;
    /**
     * 获取计量单位列表
     * @return
     * @throws BaseException
     */
	public List<KeyValueVO> getPrdUntList() throws BaseException;
	 /**
     * 获取调查报告类型列表
     * @return
     * @throws BaseException
     */
	public List<KeyValueVO> getCstRptTypList() throws BaseException;
	/**
	 * 获取商品基础和商品明细数据
	 * @param prdId
	 * @param prdDetailId
	 * @return
	 */
	public PrdBscInfoVO getPrdBscAndPrdDetailInfo(String prdId, String prdDetailId) throws BaseException;
	/**
	 * 查询商品及商品明细
	 * @param page
	 * @return
	 */
	public Pager searchPrdAndPrdDetailListPage(Pager page)throws BaseException;
	/**
	 * 卡车列表
	 * @param page
	 * @return
	 * @throws BaseException
	 */
	public Pager getPrdTKInfoPage(Pager page)throws BaseException;
	/**
	 * 乘用车列表
	 * @param page
	 * @return
	 * @throws BaseException
	 */
	public Pager getPrdCarInfoPage(Pager page)throws BaseException;
	/**
	 * 产品分类树
	 * @return
	 * @throws BaseException
	 */
	public JSONArray searchPrdTyeList() throws BaseException;
	/**
	 * 保存项目基础数据和明细数据，及卡车的挂靠公司
	 * @param prdBscInfoVO
	 * @param prdCarInfoVO
	 * @param prdTkInfoVO
	 * @return
	 */
	@Deprecated
	public Long addPrjPrdBscAndDetailInfo(PrjPrdBscInfoVO prdBscInfoVO, PrjPrdCarInfoVO prdCarInfoVO, PrjPrdTkInfoVO prdTkInfoVO)throws BaseException;
	/***
	 * 修改项目基础和明细数据，及卡车的挂靠公司
	 * @param prdBscInfoVO
	 * @param prdCarInfoVO
	 * @param prdTkInfoVO
	 * @return
	 */
	@Deprecated
	public void modifyPrjPrdBscAndDetailInfo(PrjPrdBscInfoVO prdBscInfoVO, PrjPrdCarInfoVO prdCarInfoVO,
			PrjPrdTkInfoVO prdTkInfoVO)throws BaseException;
	/**
	 * 业务种类列表
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getLoanTypCdList()throws BaseException;
	/**
	 * 判断当前用户是不是客户经理
	 * @param currRoleId
	 * @return
	 * @throws BaseException
	 */
	public boolean getCurrentUserRoleStatus(Long currRoleId)throws BaseException;

	public String getOrgTextName(Long currentOrgId);
	/**
	 * 获取考察照片列表
	 * @param qc
	 * @return
	 * @throws BaseException
	 */
	public List<SysUlFilesRecVO> searchSurveyList(SysUlFilesRecQueryCondition qc)throws BaseException;
	/**
	 * 添加项目照片考察照片/家访照片
	 * @param list
	 * @throws BaseException
	 */
	public void addPrjPhotos(List<SysUlFilesRecVO> list)throws BaseException;
	/**
	 * 通过项目ID查询项目客户类型
	 * @param prjId
	 * @return
	 * @throws BaseException
	 */
	public CstBscInfoVO getCstTypByPrjId(Long prjId)throws BaseException;
	
	/**
	 *  申请企业我司信用记录列表
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getPrjApyCrdtList() throws BaseException;
	/**
	 *  是否列表
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getYesNoList() throws BaseException;
	/**
	 * 结款方式
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getPayStlCdList() throws BaseException;
	/**
	 * 联系人方式
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getLnkTypCdList() throws BaseException;
	 /**
     * 计算方式
     * @return
     * @throws BaseException
     */
	public List<KeyValueVO> searchLsCalWayCdList() throws BaseException;
	/**
	 * 租赁年利率计算方式
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchIntRateWayCdList() throws BaseException;
	/**
	 * 不还款处理方式
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchNoPayWayCdList() throws BaseException;
	/**
	 * 设备大类 - AUD0001
	 * @return
	 * @throws BaseException
	 */
	//public List<KeyValueVO> searchEquCategoryCdList() throws BaseException;
	
	/**
	 * 设备大类 - AUD0001
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchEquCategoryCdList(String sysCd, String orgCd) throws BaseException;
	/**
	 * 放款方式 - MFR0001
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchPayWayCdList(String sysCd, String orgCd) throws BaseException;
	/**
	 * 车辆级别 - AUD0033
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchCarLevelCdList() throws BaseException;
	/**
	 * 农机设备大类 - AUD0034
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchFarmEquCategoryCdList() throws BaseException;
	/**
	 * 投保状态
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchInsStsCdList() throws BaseException;
	/**
	 * 拷贝客户信息到项目客户
	 * @return
	 * @throws BaseException
	 */
	public boolean addCopyCstInfoToPrjCstInfo(Long prjId) throws BaseException;
	/**
	 * 查询折旧率信息
	 * @return
	 * @throws BaseException
	 */
	public Map<String, String> getDiscountRate()throws BaseException;
	/**
	 * 生成合同编号
	 * @param prjId
	 * @param currentSysCd
	 * @param currentOrgCd
	 * @return
	 */
	public String generateContractCode(Long prjId, String currentSysCd, String currentOrgCd)throws BaseException;
	/**
	 * 通过ID列表删除
	 * @param idList
	 * @throws BaseException
	 */
	public void removeByIds(List<Long> idList,Long usrId)throws BaseException;
	/**
	 * 导出资信信息
	 * @param cstId
	 * @param prjId
	 * @throws BaseException
	 */
	public Document exportInvesstRpt(Long prjId, Long cstId,String cstRlCd,OutputStream out)throws BaseException;
	//品牌类别
	public List<KeyValueVO> getBrTypCdList()throws BaseException;
	//产品种类
	public List<KeyValueVO> getPrdClsCdList()throws BaseException;
	//保险购买方式
	public List<KeyValueVO> getBuyWayCdList()throws BaseException;
	/**
	 * 业务种类
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getBizTypCdList()throws BaseException;
	
	public List<KeyValueVO> getBizTypCdDetailList()throws BaseException;
	/**
	 * 查询父级节点及当前及当前一些的所有节点
	 * @param currentOrgId
	 * @return
	 */
	public JSONArray searchParentAndCurrentAllsOrgTree(Long currentOrgId,String cstMgrOrgCd);

	public JSONArray searchBuParentAndCurrentAllsOrgTree(String cstMgrOrgCd, String userId);
	
	//检查客户是否有必填项没有填写
   public boolean checkCstRequiredField(Long cstId) throws BaseException;
  /**
   * 设备状态
   * @return
   * @throws BaseException
   */
   public List<KeyValueVO> getPrdStsCdList()throws BaseException;
   /**
    * 其他租赁物用途
    * @return
    * @throws BaseException
    */
   public JSONArray searchPrjIndTree()throws BaseException;
   /**
    * 检查项目名称是否存在
    * @param prjNm
    * @return
    * @throws BaseException
    */
   public List<PrjBscInfoVO> getPrjBscInfoByPrjNm(String prjNm)throws BaseException;
   
   /**
    * 导出担保人资信信息
    */
   public Document exportGuarInvesstRpt(Long prjId, Long cstId, Long prjCstId, String cstRlCd,OutputStream out) throws BaseException;
   /**
    * 获取与客户关系的字典选项
    * @return
    * @throws BaseException
    */
   public List<KeyValueVO> getRlCdList()throws BaseException;
   /**
    * 根据项目ID查询回访记录
    * @param prjId
    * @return
    * @throws BaseException
    */
   public List<AudReturnVisitVO> getAudReturnVisitByPrjId(Long prjId)throws BaseException;
   /**
    * 保存上传文件记录
    * @param fileQc
    * @param fileRec
    * @return
    * @throws BaseException
    */
   public Long addFileRec(SysUlFilesRecQueryCondition fileQc, SysUlFilesRecVO fileRec)throws BaseException;
   /**
    * 合同签署方式
    * @return
    * @throws BaseException
    */
  public List<KeyValueVO> getCntTypCdList() throws BaseException;
  /**
   * 上传文件列表
   * @param fileQc
   * @param fileList
   */
  public void addFileRecList(SysUlFilesRecQueryCondition fileQc, List<SysUlFilesRecVO> fileList)throws BaseException;
  /**
   * 
   * @param prjId
   * @return
   * @throws BaseException
   */
   public List<AudCreditInfoVO> getAudCreditInfoByPrjId(Long prjId)throws BaseException;
   
   
   /**
    * 拆分比例
    * @return
    * @throws BaseException
    */
  public List<KeyValueVO> getPrjQuatSplitPctList() throws BaseException;
  
  /**
   * 阶梯价每阶梯比例值  
   * @return
   * @throws BaseException
   */
 public List<KeyValueVO> getPerPctCdList() throws BaseException;
 
 
 /**
  * 阶梯价每阶梯比例值  
  * @return
  * @throws BaseException
  */
public MessageDTO<String> saveTaskTransfer(String ownerId,String assigneeId,String assigneeName) throws BaseException;
/**
 * 工行供应商使用的比例
 * @return
 * @throws BaseException
 */
public List<KeyValueVO> getSplBackPctList()throws BaseException;
/**
 * 专车客车从咨询费1拆分出来的供应商比例
 * @return
 * @throws BaseException
 */
public List<KeyValueVO> getPrjConsSplitPctList()throws BaseException;

/**
 * 项目列表增加逾期信息
 * @param listVO
 * @return
 * @throws BaseException
 */
public List<PrjBscInfoVO> putOvdDataToPrjBscInfo(List<PrjBscInfoVO> listVO)throws BaseException; 

/**
 * 获取项目汇总信息
 * @param qc
 * @return
 * @throws BaseException
 */
public PrjPopuInfoDTO getPrjPopuInfo(PrjBscInfoQueryCondition qc)throws BaseException;

public List<PrjBscInfoVO> searchPrjBscInfoList(PrjBscInfoQueryCondition qc)throws BaseException;
/**
 * 获取立项校验规则--供应商信息
 * @param prjId
 * @return
 * @throws BaseException
 */
PrjCheckResultDTO checkCreditRule(String prjId)throws BaseException;
/**
 * 根据项目ID获取前置征信列表
 * @param prjId
 * @return
 * @throws BaseException
 */
Boolean searchRcCstBscInfoByPrjId(String prjId) throws BaseException;


/**
 * @Author liumengmeng
 * @Description 预审校验：1.校验所有车辆VIN是否填写
 * 						2.必须保证挂靠公司都为空 或者挂靠公司相同
 * 						3.若为车抵贷，车牌不能为空
 * 						4.立项主体黑名单校验
 * 						5.如果挂靠公司不为空 判断产品所挂靠的公司是否有待提交的
 * @Date  2020/9/7 15:05
 * @Param [prjId]
 * @return java.lang.Boolean
 **/
void checkPreAudInfo(Long prjId, Long cstId) throws BaseException;

/**
 * 获取征信列表
 * @param buOrgCd
 * @param prjTypCd
 * @param cstId
 * @param cstMgrOrgCd
 * @param prjId
 * @param flag 默认：false 修改：true
 * @return
 * @throws BaseException
 */
public PrjCheckResultDTO  searchRcCstBscInfoList(String buOrgCd, String prjTypCd, Long cstId, String cstMgrOrgCd,Long prjId,Boolean flag,String insCode)
		throws BaseException;
/**
 * 查询厂商详情信息
 * @param prjId
 * @return
 * @throws BaseException
 */
public PrjBscInfoVO selectMfrPrjBscInfoDetai(Long prjId)throws BaseException;
/**
 * 厂商列表
 * @param page
 * @return
 * @throws BaseException
 */
public Pager searchMfrListPage(Pager page)throws BaseException;
/**
 * 前期租金比例值
 * @return
 * @throws BaseException
 */
public List<KeyValueVO> getPrjPreRntPctList()throws BaseException;

	/**
	 * 查询数据字典
	 * @param groupCd 组代码
	 * @return List<KeyValueVO>
	 */
	public List<KeyValueVO> searchCdList(String groupCd) throws BaseException;

	/**
	 * 修改签约信息
	 * @param vo
	 * @return
	 * @throws BaseException
	 */
	public boolean modifySignInfo(PrjBscInfoVO vo) throws BaseException;
	/**
	 * 商业险金额
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> searchBusinessInsCdList()throws BaseException;
	/**
	 * 牌照类别
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getLicenseCdList()throws BaseException;

	/**
	 * 保存项目基础数据和明细数据，及卡车的挂靠公司
	 * @param prdBscInfoVO
	 * @param extDTO
	 * @return
	 */
	Long addPrjPrdBscAndDetailInfo(PrjPrdBscInfoVO prdBscInfoVO, PrjPrdExtVO extDTO) throws BaseException;

	/**
	 * 修改项目基础和明细数据，及卡车的挂靠公司

	 * @param prdBscInfoVO
	 * @param extDTO
	 */
	void modifyPrjPrdBscAndDetailInfo(PrjPrdBscInfoVO prdBscInfoVO, PrjPrdExtVO extDTO) throws BaseException;
    /**
     * 分页查询所有
     * @param page
     * @return
     */
    public Pager LoansearchListPage(Pager page)throws BaseException;
    
    /**
     * 根据CODE获取平台更换银行卡数据
     * @param prjId
     * @param insCode
     * @return
     */
	public List<Map<String,Object>> selectChangeBankCardPrjPaySchInfo(Long prjId,Long cstId,String insCode) throws BaseException ;
	/*
	 * 修改项目基础扩展信息
	 */
	public Long savePrjBscExt(PrjBscExtVO prjBscExtVO)throws BaseException;
	/*
	 * 根据项目id查询
	 */
	public PrjBscExtVO selectByPrjBscExtId(Long prjId)throws BaseException;

	/**
	 * 查询验车信息是否录入车牌号
	 * @param prjId 项目id
	 * @return Long 0-未录入，1-已录入
	 * @throws BaseException
	 */
	public Long areOrNoRegistration(Long prjId)throws BaseException;
	/*
	 * 里程数据判断
	 * @param prjId 项目id
	 * @return String 验车方案
	 * @throws BaseException
	 */
	public String checkMileage(Long prjId)throws BaseException;


	/**
	 * 所属区域
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getRegionList() throws BaseException;

    /**
     * 运维功能中删除项目信息
     * @throws BaseException
     */
    public void removePassAndIngPrjBscInfoByIds(List<Long> idList,Long usrId) throws BaseException;

    /**
     * 发起非资管审核流程
     * @param prjId 项目ID
     * @return
     * @throws BaseException
     */
    public DataResultDTO addNonInsFlowStart(Long prjId, String reason, Long usrId, String usrNm)throws BaseException;


    /**
     * 验车方式字典选项
     * @return
     * @throws BaseException
     */
    public List<KeyValueVO> searchVehCheckCdList ();

	public List<KeyValueVO> getKeyValueList(String code, String sysCd, String orgCd) throws BaseException;

	/**
	 * 同步保存车源信息
	 * @param prdBscInfoVO
	 * @param extDTO
	 */
	public void modifyPrjPrdCarSourceDetailInfo(PrjPrdBscInfoVO prdBscInfoVO, PrjPrdExtVO extDTO) throws BaseException;

	/**
	 * 根据金融机构是否提供服务对客户征信结果进行筛选
	 * @param PrjCheckResultDTO
	 * @param filterFlag 是否进行筛选(0-否,1-是)
	 */
	public PrjCheckResultDTO getFilterRiskResultByIsService(PrjCheckResultDTO prjCheckResultDTO,boolean filterFlag) throws BaseException;

	/**
	 * 分页查询所有外派业务数据
	 * @param page
	 * @return
	 */
	public Pager searchExpBusinessListPage(Pager page)throws BaseException;

	/**
	 * 风险隐患
	 * @return
	 * @throws BaseException
	 */
	public List<KeyValueVO> getHidRiskList() throws BaseException;

	/**
	 * 修改实际供应商、实际联系方式
	 * @param entity
	 * @return
	 */
	public boolean modifyRealSpl(PrjBscInfoVO entity)throws BaseException;

	/**
	 * 获取预筛选项目信息及流程编号
	 * @param condition
	 * @return
	 */
	List<PrjBscInfoVO> searchPrePrjBscInfoList(PrjBscInfoQueryCondition condition) throws BaseException;

	/**
	 * 获取疫情贷的原项目id
	 * @param prjId
	 * @return
	 */
	String getPrjIdByPrjId(String prjId) throws BaseException;

	/**
	 * 判断组织架构来源是否为优车
	 * @param orgCd  组织架构
	 * @return
	 * @throws BaseException
	 */
	public boolean isYcOrgCheck(String orgCd)throws BaseException;

	/**
	 * 查询项目基本信息不包含其他处理
	 * @param id
	 * @return
	 * @throws BaseException
	 */
    PrjBscInfoVO selectPrjBscInfoById(Long id) throws BaseException;

    List<PrjBscInfoVO> searchList(PrjBscInfoQueryCondition qc );

	public Integer updateFundPrjBscInfo(PrjBscInfoVO prjBscInfoVO) throws BaseException;

    List<KeyValueVO> getCompensatoryTypeList() throws BaseException;

	List<KeyValueVO> getGuaranteePaymentTypeList() throws BaseException;

	List<KeyValueVO> getBigCstWorkSourceList() throws BaseException;
}
